package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {

    //新增用户并且需要返回id
    void addUser(User user);

    @Select("select * from user where openid=#{openid}")
    User findByOpenid(String openid);

    @Select("select * from user where id=#{id}")
    User getById(Long id);

    /**
     * 根据动态条件统计用户数量
     * @param map
     * @return
     */
    Integer countByMap(Map map);

    Integer findByBeforeDate(LocalDate beforeDate);

    @MapKey("date")
    List<Map<String, Object>> findByLocalDate(LocalDate begin, LocalDate end);
}
